/*
 * Company  : Datalogic S.p.A.
 * Title    : LIBRARY GENERAL CONSTANTS
 * Filename : GENK.INC
 * System   : Keil-Frankling C-Language Compiler
 * MemoryMod: large
 * Notes    :
 */


/* general */

typedef unsigned char UC;
typedef unsigned int  UI;
typedef unsigned char BT_ERR;
typedef unsigned char BT_STAT;

typedef enum 
{
    	BT_NOTCONNECTED=0,
        BT_CONNECTED=1
}BT_STATUS;

#define LINE		case
#define STATUS		case
#define STEP		case
#define ENDOFSTEP	return

#define ON             	0XFF
#define OFF            	0X00

#define TRUE           	0XFF
#define FALSE         	0X00

#define OK             	0XFF
#define NOK            	0X00

#define ENDED          	0XFF
#define NOENDED        	0X00

#define CR             	0X0d
#define BLANK          	0X20
#define STAR           	0X2a
#define POINT          	0X2e
#define	LF				0x0a

#define BT_FUNC_SUCCESS		1
#define BT_FUNC_FAIL		0

//Usb Profile set
#define USBserial     0x01
#define kbdEmulation  0x02 
#define USBMSD        0x03
#define MSK_CONFG     0x02 

#define English  1
#define Italian  2


#define DEL           0X7f	/* not implemented in putchar as control character*/


/* operating system: software timers */

#define IDLETIM        	'I'
#define RUNTIM         	'R'
#define ENDTIM         	'E'

#define NOENDTIMCALL   ( void(*)(void) ) 0X0000 /* no funct call at timer end */

#define N_MAX_TIMERS   	30
#define N_MAX_TASKS     15

//changes: 14/06/07: basic timer tick @ 25msec.
#define TICK_FREQ      	40 //20                      // rtc freq.( Hz )

#define T50MS          	1 * 2
#define T100MS         	2 * 2
#define T150MS         	3 * 2
#define T200MS         	4 * 2
#define T250MS         	5 * 2
#define T300MS         	6 * 2
#define T350MS         	7 * 2
#define T400MS         	8 * 2
#define T450MS         	9 * 2
#define T500MS         	10 * 2
#define T600MS         	12 * 2
#define T700MS         	14 * 2
#define T800MS         	16 * 2
#define T900MS         	18 * 2
#define T1000MS         20 * 2
#define T2000MS         40 * 2

#define T1SEC          	1   * TICK_FREQ
#define T2SEC          	2   * TICK_FREQ
#define T3SEC          	3   * TICK_FREQ
#define T4SEC          	4   * TICK_FREQ
#define T5SEC          	5   * TICK_FREQ
#define T6SEC          	6   * TICK_FREQ
#define T7SEC          	7   * TICK_FREQ
#define T8SEC          	8   * TICK_FREQ
#define T9SEC          	9   * TICK_FREQ
#define T10SEC         	10  * TICK_FREQ
#define T20SEC         	20  * TICK_FREQ
#define T30SEC         	30  * TICK_FREQ
#define T40SEC         	40  * TICK_FREQ
#define T50SEC         	50  * TICK_FREQ
#define T1MIN          	60  * TICK_FREQ
#define T10MIN         	600 * TICK_FREQ

#define TENTH          	* 2 * 2
#define TENTHS         	* 2	* 2
#define SECOND         	* TICK_FREQ
#define SECONDS        	* TICK_FREQ
#define MINUTE         	* 60 * TICK_FREQ
#define MINUTES        	* 60 * TICK_FREQ


#define T_MIN   	1	// T50MS
#define T_MAX		65535	// 54 MINUTES + 36 SECONDS + T700MS + T50MS

/* power saving self shut down default time: IT IS SUGGESTED NOT TO EXCEED 10 SECONDS */

#define T_PSSSD        	7 SECONDS


/* operating system: scheduler multitask */

#define INITSK		'I'
#define SLEEPTSK	'S'
#define READYTSK	'R'
#define EXECTSK		'E'
#define DELAYTSK	'D'

#define WAITSK      'W'                     // not implemented


// operating system: wakeup modality

#define D_set		'D'
#define T_set		'T'
#define W_set		'W'
#define N_set		'N'


/* operating system: ring constants */

#define C4_RN          	1    /* ring notes (beeps are not in tune with musical notation) */
#define D4_RN          	2
#define E4_RN          	3
#define F4_RN          	4
#define G4_RN          	5
#define A4_RN          	6
#define B4_RN          	7
#define C5_RN          	8
#define D5_RN          	9
#define E5_RN          	10
#define F5_RN          	11
#define G5_RN          	12
#define A5_RN          	13
#define B5_RN          	14
#define C6_RN          	15
#define D6_RN          	16
#define MIN_RN         	C4_RN
#define MAX_RN         	D6_RN

#define MIN_RD         	1    /* ring durations (mS) */
#define VERY_SHORT_RD   10
#define SHORT_RD       	20
#define MEDIUM_RD      	50
#define LONG_RD        	80
#define VERY_LONG_RD	100
#define MAX_RD         	120

/* display dimensions */

#define D16X4_NDSPCOLUMNS	16
#define D16X4_NDSPROWS      15
#define D16X4_NDSPCHARS      	D16X4_NDSPCOLUMNS * D16X4_NDSPROWS

/* memory bank constants */

#define RAMBANKBASEADDR      	(unsigned char xdata *) 0X8000
#define RAMBANKUNITDIM       	0X8000

#define IR_INTERFACE	0X01
#define RF_INTERFACE	0X02

//#define INTERFACE_TYPE	RF_INTERFACE

/*
 * operating system: scheduler task allocation and
 * procedure identifiers (also used in fault message)
 */

#define PROC_TKDRVACQ   		0    /* proc. id. = proc. priority in hdlbc.lib */
#define PROC_TKSTATCTRL      	1    /* proc. id. = proc. priority in mainds.lib */
#define PROC_TKDRVKEY         	2    /* proc. id. = proc. priority in hdlkbxxx.lib */
#define PROC_TK_ENDTIM       	3    /* proc. id. = proc. priority in mainds.lib */
#define PROC_TKCLOCK         	4    /* proc. id. = proc. priority in hdlckxxx.lib */
#define PROC_TKRING          	5    /* proc. id. = proc. priority in mainds.lib */
#define PROC_TKAPL           	6    /* proc. id. = proc. priority in apl.obj */
#define PROC_TKUSERAPL1      	7    /* proc. id. = proc. priority in apl.obj */
#define PROC_TKUSERAPL2      	8    /* proc. id. = proc. priority in apl.obj */
#define PROC_TKUSERAPL3      	9    /* proc. id. = proc. priority in apl.obj */
#define PROC_TKAUTORPT       	10   /* proc. id. = proc. priority in hdlkbxxx.lib */
#define PROC_TKIR        	    11   /* proc. id. = proc. priority in rf.lib,newrf.lib,rf1.lib */

/* bootstrap-loader: procedure identifiers (used in fault message) */

#define PROC_BOOTSTRAP_MAIN  	21   /* proc. id. in bootstrap-loader */
#define PROC_BAUDRATEERRCOM   	22   /* proc. id. in bootstrap-loader */
#define PROC_FLASH_ERASE      	23   /* proc. id. in bootstrap-loader */
#define PROC_FLASH_CLEAR      	24   /* proc. id. in bootstrap-loader (only v3r0) */
#define PROC_FLASH_DUMP_CODE  	25   /* proc. id. in bootstrap-loader */
#define PROC_IHEX_DECODER    	26   /* proc. id. in bootstrap-loader */
#define PROC_BL_RD_KEYS    		27   /* proc. id. in bootstrap-loader */
#define PROC_USB_EMPTY_LIB		28	 /* proc. id. in USBHDL.c */
#define PROC_MMC_FILE_NP        29   /* .Hex and .H00 file NP(Not present)*/
#define PROC_PARITYERRCOM    	52   /* proc. id. in bootstrap-loader */

/* operating system: procedure identifiers (used in fault message) */

#define PROC_IR_HREQST          12   /* proc. id. in rf.lib,newrf.lib,rf1.lib */
#define PROC_MAIN            	31   /* proc. id. in mainds.lib */
#define PROC_HARDWARE_TESTS  	32   /* proc. id. in mainds.lib */
#define PROC_TEST_RAMX       	34   /* proc. id. in mainds.lib */
#define PROC_TEST_BANKSEL    	36   /* proc. id. in mainds.lib */
#define PROC_CHECK_RAM_CONF  	37   /* proc. id. in mainds.lib */
#define PROC_RQSTSK          	39   /* proc. id. in mainds.lib */
#define PROC_RDYTSK          	40   /* proc. id. in mainds.lib */
#define PROC_SLPTSK          	41   /* proc. id. in mainds.lib */
#define PROC_STATSK          	42   /* proc. id. in mainds.lib */
#define PROC_DLYTSK          	43   /* proc. id. in mainds.lib */
#define PROC_RQTIM           	44   /* proc. id. in mainds.lib */
#define PROC_WRTIM           	45   /* proc. id. in mainds.lib */
#define PROC_RDTIMC          	46   /* proc. id. in mainds.lib */
#define PROC_RDTIMST         	47   /* proc. id. in mainds.lib */
#define PROC_ISPECHAR        	48   /* proc. id. in mainds.lib */
#define PROC_EXIT_TO_BL      	49   /* proc. id. in mainds.lib */
#define PROC_WRITECLOCK      	51   /* proc. id. in hdlckxxx.lib */
#define PROC_DEC_HREQST      	53   /* proc. id. in hdlbc.lib */
#define PROC_DECODER_HDL     	55   /* proc. id. in hdlbc.lib */
#define PROC_ENA_SYMBLG      	56   /* proc. id. in hdlbc.lib */
#define PROC_DIS_SYMBLG      	57   /* proc. id. in hdlbc.lib */
#define PROC_ENA_SYMBLGCHKSM 	58   /* proc. id. in hdlbc.lib */
#define PROC_DIS_SYMBLGCHKSM 	59   /* proc. id. in hdlbc.lib */
#define PROC_TX_HREQST       	60   /* proc. id. in hdlcom00.lib,hdlcom10.lib */
#define PROC_KB_HREQST       	63   /* proc. id. in hdlkbxxx.lib */
#define PROC_RD_KEYS         	64   /* proc. id. in hdlkbxxx.lib */
#define PROC_WR_E2PROM	     	65   /* proc. id. in e2pxxxxx.lib */
#define PROC_RD_CSIN	        66   /* proc. id. in drvgen.lib */
#define PROC_E2PROM       	67   /* proc. id. in e2pxxxxx.lib */
#define PROC_SETWAKEUP       	68   /* proc. id. in hdlckxxx.lib */
#define PROC_IIC_READ_CLOCK     88   /* proc. id. in hdlckxxx.lib */
#define PROC_IIC_WRITE_CLOCK    99   /* proc. id. in hdlckxxx.lib */

// FLASH WRITE/ERASE CONSTANTS

#define		TIMEOUT_BIT 		0x20
#define		POLL_CHECK_BIT		0x80 

//MMCSD USB  Mass Storage

#define CARD_REMOVED   			 0
#define CABLE_REMOVED 			 1
#define COMM_SUCCESS			 3
#define COMM_ERROR    			 0xFE	

#define INSERTED         		 0
#define REMOVED           		 1
#define EMPTY             		 0	

//SET EVENTS
#define NO_EVENT 			    0x0
#define RS232_EVENT 			0x1
#define MMCSD_EVENT 			0x2
#define DCIN_EVENT  			0x4
#define USB_EVENT   			0x8
#define DEFAULT_EVENT   		RS232_EVENT

// FONT VALUES

#define NORMAL_FONT 0
#define WIDE_FONT   1